  //心电数据

  //心率
  function getTime(num1, num2) {
      $.ajax({
                  url: `${Url}/Wechat/Api/PeriodECG?IdentityNo=${theRequest.IdentityNo}&BeginTime=${num1}&EndTime=${num2}`,
                  type: 'get',
                  datatype: 'json',
                  headers: {
                      'Authorization': Authorization
                  },
                  // data: responseData,
                  async: false,
                  success: function(res) {
                          var num6 = res.data.ECGItems;
                          var HeartRate = [];
                          var ExamId = [];
                          if (num6.length > 0) {

                              for (let key in num6) {
                                  var con = num6[key]
                                  HeartRate.push(con.HeartRate);
                                  ExamId.push(con.ExamId);
                              }
                          } else {
                              $('#tabletext').css('display', 'none')
                          }
                          let teplhtml = `
              ${num6.map(item=>{
                return `<tr><td>${item.CheckDate}</td><td>${item.HeartRate}</td></tr>`
            }).join('')
        }
             `

              $('#tabletext').html(teplhtml);
              if (HeartRate.length == 0) {
                  max = 110;
                  min = 50;
              } else {
                  max = Math.max.apply(null, HeartRate) + 10,
                      min = eval("Math.min(" + HeartRate + ")") - 11
              }
              var myChart1 = echarts.init(document.getElementById('main1'));
              option1 = {
                  title: {
                      text: '心率检测数据',
                      subtext: '心率脉率:60~100次/分',
                      x: 'right',

                  },
                  grid: {


                      top: "30%",
                      right: "0%",
                      bottom: '10%',
                      //     width: "66%",
                      left: "10%",
                      //     containLabel: true,
                      //     height: "55%"
                  },

                  legend: {
                      orient: 'vertical',
                      x: 'left',
                      y: 'top',
                      data: ['心率'],

                  },
                  xAxis: {
                      show: false,
                      data: [ExamId],
                      //   data: [1, 2]
                  },
                  yAxis: {
                      max: max,
                      min: min,
                      axisLabel: {
                          interval: 0
                      },
                  },
                  series: [{
                      name: '心率',
                      type: 'line',
                      dataIndex: 1,
                      data: HeartRate,
                      //   data: [1, 2],
                      markLine: {
                          symbol: ['none', 'none'], //去掉箭头
                          itemStyle: {
                              normal: {
                                  lineStyle: {
                                      type: 'dashed',
                                      color: { //设置渐变
                                          type: 'linear',
                                          x: 0,
                                          y: 0,
                                          x2: 0,
                                          y2: 1,
                                          colorStops: [{
                                              offset: 0,
                                              color: 'red ' // 0% 处的颜色
                                          }, {
                                              offset: 1,
                                              color: 'red' // 100% 处的颜色
                                          }],
                                          global: false // 缺省为 false
                                      }
                                  },
                              }
                          },
                          data: [{
                              yAxis: 60,
                          }, {
                              yAxis: 100,
                          }]
                      },

                  }],
                  color: ['#3366CC'],
                  tooltip: {
                      trigger: 'axis',
                      axisPointer: {
                          type: 'line'
                      }
                  },
              };
              myChart1.setOption(option1);

              myChart1.on('click', function (params) {
                  var options = 'I';
                  $('.select').css('display', 'block')
                  //   var params = params
                  $('.select button').click(function () {
                      options = $("#skills option:selected").val();
                      $('.ecgDispaly').css('display', 'block');


                      function a() {
                          $.ajax({
                              url: `${Url}/Wechat/Api/EcgData?ExamId=${params.name}&EcgType=${options}`,
                              type: 'get',
                              datatype: 'json',
                              headers: {
                                  'Authorization': Authorization
                              },
                              // data: responseData,
                              async: false,
                              success: function (res) {
                                  var myChart2 = echarts.init(document.getElementById('main2'));
                                  option2 = {
                                      title: {
                                          text: options + '导检测数据',
                                          //   subtext: '心率脉率:60~100次/分',
                                          x: 'right',
                                      },
                                      grid: {
                                          top: "30%",
                                          right: "0%",
                                          bottom: '20%',
                                          //     width: "66%",
                                          left: "10%",
                                          //     containLabel: true,
                                          //     height: "55%"
                                      },
                                      legend: {
                                          orient: 'vertical',
                                          x: 'left',
                                          y: 'top',
                                          data: [options + '导'],

                                      },
                                      xAxis: {
                                          show: false,
                                          data: res.data.EcgData.split(","),
                                          axisLabel: {
                                              interval: 0
                                          },
                                      },
                                      yAxis: {
                                          max: Math.max.apply(null, res.data.EcgData.split(",")) + 10,
                                          min: eval("Math.min(" + res.data.EcgData.split(",") + ")") - 11,
                                          axisLabel: {
                                              interval: 0
                                          },
                                          //   data: ['600', "500"],
                                      },
                                      series: [{
                                          name: options + '导',
                                          type: 'line',
                                          data: res.data.EcgData.split(","),
                                          showAllSymbol: true,
                                          showSymbol: false,
                                          markLine: {
                                              symbol: ['none', 'none'], //去掉箭头
                                              itemStyle: {
                                                  normal: {
                                                      lineStyle: {
                                                          type: 'dashed',
                                                          color: { //设置渐变
                                                              type: 'linear',
                                                              // x: 0,
                                                              y: 0,
                                                              x2: 0,
                                                              y2: 1,
                                                              colorStops: [{
                                                                  offset: 0,
                                                                  color: 'red ' // 0% 处的颜色
                                                              }, {
                                                                  offset: 1,
                                                                  color: 'red' // 100% 处的颜色
                                                              }],
                                                              global: false // 缺省为 false
                                                          }
                                                      },
                                                  }
                                              },
                                              data: [{
                                                  yAxis: Math.max.apply(null, res.data.EcgData.split(",")),
                                              }, {
                                                  yAxis: eval("Math.min(" + res.data.EcgData.split(",") + ")"),
                                              }]
                                          },

                                      }],
                                      color: ['#3366CC'],
                                      tooltip: {
                                          trigger: 'axis',
                                          axisPointer: {
                                              type: 'line'
                                          }
                                      },
                                      dataZoom: [ //滑动条
                                          {
                                              type: 'inside',
                                              realtime: true,
                                              // start: startLength,
                                              end: 100,
                                              startValue: 0
                                          }
                                      ],
                                  };
                                  myChart2.setOption(option2);
                              }
                          })
                      }
                      a()
                  })



                  //   a()
                  //I导图

                  //   //II导图
                  //   var myChart3 = echarts.init(document.getElementById('main3'));
                  //   option3 = {
                  //       title: {
                  //           text: 'I导检测数据',
                  //           //   subtext: '心率脉率:60~100次/分',
                  //           x: 'right',
                  //       },
                  //       grid: {
                  //           top: "30%",
                  //           right: "0%",
                  //           bottom: '20%',
                  //           //     width: "66%",
                  //           left: "10%",
                  //           //     containLabel: true,
                  //           //     height: "55%"
                  //       },
                  //       legend: {
                  //           orient: 'vertical',
                  //           x: 'left',
                  //           y: 'top',
                  //           data: ['I导'],

                  //       },
                  //       xAxis: {
                  //           show: false,
                  //           data: con.I.split(","),
                  //           axisLabel: {
                  //               interval: 0
                  //           },
                  //       },
                  //       yAxis: {
                  //           max: Math.max.apply(null, con.II.split(",")) + 10,
                  //           min: eval("Math.min(" + con.I.split(",") + ")") - 11,
                  //           axisLabel: {
                  //               interval: 0
                  //           },
                  //           //   data: ['600', "500"],
                  //       },
                  //       series: [{
                  //           name: 'I导',
                  //           type: 'line',
                  //           data: con.II.split(","),
                  //           showAllSymbol: true,
                  //           showSymbol: false,
                  //       }],
                  //       color: ['#3366CC'],
                  //       tooltip: {
                  //           trigger: 'axis',
                  //           axisPointer: {
                  //               type: 'line'
                  //           }
                  //       },
                  //       dataZoom: [ //滑动条
                  //           {
                  //               type: 'inside',
                  //               realtime: true,
                  //               // start: startLength,
                  //               end: 100,
                  //               startValue: 0
                  //           }
                  //       ],
                  //   };
                  //   myChart3.setOption(option3);
              });



          }
      })
  }
  getTime(getPreMonth(), getNowMonth());